package controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LoginController {
	@RequestMapping(path = {"/login"},
			method = {RequestMethod.GET,RequestMethod.POST} ,
			consumes = {MediaType.APPLICATION_JSON_VALUE ,MediaType.TEXT_PLAIN_VALUE}
	,produces ={MediaType.APPLICATION_JSON_UTF8_VALUE,MediaType.TEXT_PLAIN_VALUE})
			
	@ResponseBody
	public String login(HttpServletResponse resp,String name ,String password){
		resp.setCharacterEncoding("UTF-8");
		 resp.setContentType("text/html;charset=utf-8");
		String msg = "name"+ name +", passwd= " + password;
		System.out.println(msg);
		return msg;
	}
	
	@RequestMapping("/echo")
	@ResponseBody
	public String echo(String message){
		return message;
	}
	 
}
